using System;
using System.Globalization;
using System.Windows.Data;

namespace vlcplay.Converters
{
    public class BoolToOpacityConverter : IValueConverter
    {
        public double TrueOpacity { get; set; } = 0.7;
        public double FalseOpacity { get; set; } = 0.0;

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool b = value is bool v && v;
            if (parameter != null && double.TryParse(parameter.ToString(), out double p))
                return b ? p : 0.0;
            return b ? TrueOpacity : FalseOpacity;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            => throw new NotImplementedException();
    }
}